var updatedisfun = null
layui.use(['form', 'layer', 'table', 'laytpl', 'laydate', 'dropdown', 'upload'], function () {
	var form = layui.form,
		layer = parent.layer === undefined ? layui.layer : top.layer,
		$ = layui.jquery,
		table = layui.table,
		dropdown = layui.dropdown,
		laydate = layui.laydate,
		company_id = sessionStorage["company_id"],
		scale = sessionStorage["scale"],
		educationType = sessionStorage["educationType"],
		user_id = sessionStorage["userId"],
		tips_info = null;

	form.on('select(recycle_bin)', function () {
		$(".search_btn").click();
	})

	$('#openExcel').on('click', function () {
		$('#uploadExcel').click();
	})

	$('#uploadExcel').on('change', function (e) {//解析excel
		const loading = layer.msg('数据解析中，请稍候...', { icon: 16, time: false, shade: 0.7 });
		const time = getTime();
		const tableHead = {
			name: "姓名",
			cardid: "身份证号",
			phone: "手机",
			tid: "报名老师",
			school: "院校",
			major: "专业",
			educationType: "学历类型",
			cengci: "专本层次",
			ispay: "是否缴费",
			money: "缴费金额",
			isBao: "是否报名",
			signUpYear: "报名年份",
			signUpTime: "报名时间",
			veteran: "退伍军人",
			remarks: "备注"
		};

		const reader = new FileReader();
		reader.readAsArrayBuffer(e.target.files[0]);
		reader.onload = function (e) {
			let data = e.target.result;
			const workbook = XLSX.read(data, { type: 'binary', cellDates: true });
			const wsname = workbook.SheetNames[0];
			let outdata = XLSX.utils.sheet_to_json(workbook.Sheets[wsname]);
			outdata.forEach(item => {
				for (let key in item) {
					for (let k in tableHead) {
						if (key == tableHead[k]) {
							updatePropertyName(key, k, outdata);
							continue;
						}
					}
				}
				item.company_id = company_id;
				item.creattime = time;
			})
			$.ajax({
				url: baseUrl + "student/importStudents.php",
				data: {
					students: outdata
				},
				type: "POST",
				async: false,
				dataType: "text",
				success: function (data) {
					$('#uploadExcel').val('')
					if (data > 0) {
						layer.close(loading);
						tableIns.reload();
						layer.msg('成功导入 ' + data + ' 条数据!');
					}
				}
			})
		}
	})

	if (scale == 1 || scale == 2) {
		$('.updates').removeClass("layui-hide");
		$('#tName').append(getTeacherList({ tname: '' }));
	}
	if (user_id == 3) {
		loadCompanyList(form, $);
		$('.company').removeClass("layui-hide");
		$('.recycle_bin').removeClass("layui-hide");
	}
	//加载层次学历类型下拉列表
	loadSelect(form, $, "cengci/getCengci.php", "#cengci")
	loadSelect(form, $, "educationType/getEducationType.php", "#educationType")
	form.render('select')
	//学生列表
	var tableIns = table.render({
		elem: '#studentList',
		url: baseUrl + 'student/getStudents.php',
		where: {
			educationType,
			scale,
			userid: user_id,
			company_id,
			recycle_bin: 0
		},
		// skin: "row",//line
		// size: "lg",//sm
		even: true, //开启隔行背景
		toolbar: true,//右上角工具栏
		cellMinWidth: 100,
		page: true,
		limits: [10, 20, 50, 100],
		limit: 10,
		id: "studentListTable",
		cols: [
			[{
				type: 'checkbox',
				fixed: 'left',
				align: 'center'
			}, {
				title: '序号',
				type: "numbers",
				fixed: 'left',
				align: 'center'
			}, {
				field: 'id',
				title: 'ID',
				hide: true,
				fixed: 'left',
				align: 'center'
			}, {
				field: 'name',
				title: '姓名',
				fixed: 'left',
				minWidth: 75,
				align: 'center'
			}, {
				field: 'cardid',
				title: '身份证号',
				align: 'center',
				minWidth: 175,
				templet: function (d) {
					return '<span>' + d.cardid + '\t' + '</span>';
				}
			}, {
				field: 'phone',
				title: '手机',
				minWidth: 120,
				align: 'center',
				templet: function (d) {
					return '<span>' + d.phone + '\t' + '</span>';
				}
			}, {
				field: 'tname',
				title: '报名老师',
				minWidth: 86,
				align: 'center'
			}, {
				field: 'veteran',
				title: '退伍军人',
				minWidth: 86,
				align: 'center',
				templet: function (d) {
					return d.veteran == 0 ? '否' : '<span class="layui-badge layui-bg-green">是</span>';
				}
			}, {
				field: 'school',
				title: '院校',
				minWidth: 200,
				align: 'center'
			}, {
				field: 'major',
				title: '专业',
				minWidth: 150,
				align: 'center'
			}, {
				field: 'educationType',
				title: '学历类型ID',
				minWidth: 160,
				align: 'center',
				hide: true
			}, {
				field: 'educationtype_name',
				title: '学历类型',
				minWidth: 160,
				align: 'center'
			}, {
				field: 'cengci',
				title: '层次ID',
				minWidth: 160,
				align: 'center',
				hide: true
			}, {
				field: 'cengci_name',
				title: '考生层次',
				minWidth: 86,
				align: 'center'
			}, {
				field: 'ispay',
				title: '是否缴费',
				minWidth: 86,
				align: 'center',
				templet: function (d) {
					if (d.ispay != 0) {
						return '<span style="color: #e4393c;">已缴费</span>';
					} else {
						return '未缴费';
					}
				}
			}, {
				field: 'money',
				title: '缴费金额',
				minWidth: 86,
				align: 'center',
				style: 'cursor: pointer;',
				/*hide: scale == 1|| scale==2 ? false : true,*/
				event: scale > 0 ? 'update|money' : '',
				templet: function (d) {
					return d.money > 0 ? '￥' + d.money : d.money
				}
			}, {
				field: 'oweafee',
				title: '欠费金额',
				minWidth: 86,
				align: 'center',
				style: 'cursor: pointer;',
				event: scale > 0 ? 'update|oweafee' : '',
				templet: function (d) {
					return d.oweafee != '0' ? '￥' + d.oweafee : d.oweafee
				}
			}, {
				field: 'Refund',
				title: '提成',
				minWidth: 195,
				align: 'center',
				hide: scale != 1 ? true : false,
				templet: function (d) {
					var str = d.isRefund != '0' ? '<span style="color:red">已发放</span>' : '未发放';
					return `<input disabled name="reFund" class="layui-input ticheng" autocomplete="off" value = "${d.Refund}" style="width:70px;display:inline;"/> <a id="${d.id}" style="display:inline-block;" class="layui-btn layui-btn-sm" lay-event="ticheng" onclick="updatedisfun(this);">确认</a> ${str}`
				}
			}, {
				field: 'creattime',
				title: '录入时间',
				minWidth: 195,
				align: 'center'
			}, {
				field: 'remarks',
				title: '备注',
				minWidth: 86,
				align: 'center',
				style: 'cursor: pointer;',
				event: 'update|remarks'
			}, {
				field: 'isTi',
				title: '提交资料',
				minWidth: 86,
				align: 'center',
				templet: function (d) {
					if (d.isTi == 0) {
						return '未提交';
					} else {
						return '<span style="color: #e4393c;">已提交</span>';
					}
				}
			}, {
				field: 'isBao',
				title: '报名',
				minWidth: 86,
				align: 'center',
				templet: function (d) {
					if (d.isBao == 0) {
						return '未报名';
					} else {
						return '<span style="color: #e4393c;">已报名</span>';
					}
				}
			}, {
				field: 'unifiedExam',
				title: '统考课',
				minWidth: 86,
				align: 'center',
				hide: true,
				templet: function (d) {
					if (d.unifiedExam == 0) {
						return '无';
					} else {
						return '<span style="color: #e4393c;">统考课</span>';
					}
				}
			}, {
				field: 'paper',
				title: '论文',
				minWidth: 86,
				align: 'center',
				hide: true,
				templet: function (d) {
					if (d.paper == 0) {
						return '无';
					} else {
						return '<span style="color: #e4393c;">论文</span>';
					}
				}
			}, {
				field: 'baccalaureate',
				title: '学士学位',
				minWidth: 86,
				align: 'center',
				hide: true,
				templet: function (d) {
					if (d.baccalaureate == 0) {
						return '无';
					} else {
						return '<span style="color: #e4393c;">学士学位</span>';
					}
				}
			},
			{
				minWidth: 86,
				field: scale == 1 ? 'chengben' : '',
				title: scale == 1 ? '成本' : '',
				align: 'center',
				style: 'cursor: pointer;',
				style: scale == 1 ? 'cursor: pointer;' : '',
				event: scale == 1 ? 'update|chengben' : '',
				hide: scale == 1 ? false : true
			},
			{
				field: 'signUpYear',
				title: '报名年份',
				minWidth: 86,
				align: 'center',
			},
			{
				field: 'signUpTime',
				title: '报名时间',
				minWidth: 86,
				align: 'center',
				templet: function (d) {
					return d.signUpTime == 0 ? '春季' : '秋季';
				}
			},
			{
				field: 'companyName',
				title: '所属公司',
				align: 'center',
				minWidth: 220,
				hide: true
			},
			{
				field: 'downLoadPath',
				title: '报考资料',
				align: 'center',
				hide: true,
				width: 170,
				fixed: "right",
				templet: function (d) {
					return d.downLoadPath ? `<a class="layui-btn layui-btn-sm layui-bg-blue layui-btn-radius" href="/enroll/upload/${d.downLoadPath}"><i class="layui-icon">&#xe601;</i>下载</a><a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius upload" lay-event="upload"><i class="layui-icon">&#xe681;</i>上传</a><input id="upload_${d.id}" class="layui-hide" type="file" accept="application/zip,application/x-zip,application/x-zip-compressed" />` : `<a class="layui-btn layui-btn-sm layui-btn-radius layui-btn-disabled"><i class="layui-icon">&#xe601;</i>下载</a><a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius upload" lay-event="upload"><i class="layui-icon">&#xe681;</i>上传</a><input id="upload_${d.id}" class="layui-hide" type="file" accept="application/zip,application/x-zip,application/x-zip-compressed" />`;
				}
			},
			{
				title: '操作',
				width: 215,
				templet: '#studentListBar',
				fixed: "right",
				align: "center"
			}]
		],
		done: function (res, curr, count) {// done 数据表格加载完成

			$('.upload').hover(function () {
				tips_info = layer.tips('请将学生照片及相关资料打包后上传，支持 ZIP、RAR 格式', this, { tips: [1, '#2F4056'], time: 10000 });
			}, function () {
				layer.close(tips_info);
			})

			if (scale == 1) $('.ticheng').removeAttr("disabled");
			if (scale == 1 || scale == 2) {
				$('.searchTeacher').css('display', 'inline-block')
			}
			//操作 更多 下拉
			dropdown.suite();
			//获取批量操作状态
			if (res.data) {
				for (var i = 0; i < res.data.length; i++) {
					dropdown.onFilter("ft" + res.data[i].id, function (event) {
						var arr = event.split("-");
						switch (arr[1]) {
							case "baoming":
								//batch返回批量操作参数
								layer.confirm('确定为该学员报名吗？', function (index) {
									isUpdata(arr[0], 1, batch(table.checkStatus(tableIns.config.id)));
									layer.close(index);
								});
								break;
							case "jiaofei":
								layer.confirm('确定帮助选中学生缴费吗？', function (index) {
									isUpdata(arr[0], 2, batch(table.checkStatus(tableIns.config.id)));
									layer.close(index);
								});
								break;
							case "qxjiaofei":
								layer.confirm('确定取消学员缴费信息吗？', function (index) {
									isUpdata(arr[0], 4, batch(table.checkStatus(tableIns.config.id)));
									layer.close(index);
								});
								break;
							case "del":
								layer.confirm('确定删除学员信息吗？', function (index) {
									if (arr[2] > 0) {
										if (scale == 1) {
											isUpdata(arr[0], 5, batch(table.checkStatus(tableIns.config.id)));
											layer.close(index);
										} else {
											layer.msg('已经缴费不可以删除！')
										}
									} else {
										isUpdata(arr[0], 5, batch(table.checkStatus(tableIns.config.id)));
										layer.close(index);
									}
								});
								break;
							case "isRefund":
								layer.confirm('确定给予返费吗？', function (index) {
									isRefund(arr[0], batch(table.checkStatus(tableIns.config.id)));
									layer.close(index);
								});
								break;
							case "quxiao":
								layer.confirm('确定取消学员报名吗？', function (index) {
									isUpdata(arr[0], 3, batch(table.checkStatus(tableIns.config.id)));
									layer.close(index);
								});
								break;
							case "huifu":
								layer.confirm('是否确定恢复？', function (index) {
									isUpdata(arr[0], 10, batch(table.checkStatus(tableIns.config.id)));
									layer.close(index);
								});
								break;
						}
					});
				}
			}

			//发放提成
			updatedisfun = function (event) {
				if (scale != "1") {
					return;
				}
				$.ajax({
					url: baseUrl + "student/updateIsFanMoney.php",
					data: {
						id: $(event).attr("id"),
						Refund: $(event).prev().val(),
						num: 2
					},
					type: "POST",
					dataType: "text",
					success: function (data) {
						if (data == 1) {
							layer.msg('操作成功！')
							tableIns.reload()
						} else {
							layer.msg('操作失败！')
						}
					}
				})
			}
		}
	});
	//渲染时间控件
	function renderTimeControl(elem, format, type) {
		laydate.render({ elem, format, type });
	};
	renderTimeControl('#createtime', 'yyyy年MM月', 'month');
	renderTimeControl('#signUpYear', 'yyyy年', 'year');
	renderTimeControl('#updateYear', 'yyyy年', 'year');
	//input键入Enter后重载数据表格
	$('.search').on('keyup', function (event) {
		if (event.keyCode != 13) return
		$(".search_btn").click()
	})

	//搜索
	$(".search_btn").on("click", function () {
		//表格重载
		table.reload("studentListTable", {
			page: {
				curr: 1 //重新从第 1 页开始
			},
			where: {
				educationType: $("#educationType").val(),
				searchName: $("#searchtName").val(),
				searchCardid: $("#searchCardid").val(),
				searchTeacher: $("#searchTeacher").val(),
				searchSchool: $("#searchSchool").val(),
				ispay: $("#ispay").val(),
				isBao: $("#isBao").val(),
				createtime: $('#createtime').val(),
				province: $('#province').val(),
				searchUnifiedExam: $('#searchUnifiedExam').val(),
				searchPaper: $('#searchPaper').val(),
				searchBaccalaureate: $('#searchBaccalaureate').val(),
				signUpTime: $('#signUpTime').val(),
				signUpYear: $('#signUpYear').val(),
				cengci: $('#cengci').val(),
				veteran: $('#veteran').val(),
				company_id: user_id == 3 ? $('#company').val() : company_id,
				recycle_bin: $('#recycle_bin').val()
			}
		})
	});
	//学员编辑
	function editStudent(edit) {
		var index = layui.layer.open({
			title: edit ? "修改学员" : "添加学员",
			type: 2,
			area: ['80%', '80%'],
			fixed: false, //不固定
			maxmin: true,
			shadeClose: true,
			content: "studentEdit.html",
			success: async function (layero, index) {
				var body = layui.layer.getChildFrame('body', index);
				(await loadSelect(form, $, 'educationType/getEducationType.php', '', 'edit')).forEach(item => {
					if (index != 0) body.find('.educationType').append(new Option(item.name, item.id))
				});
				(await loadSelect(form, $, 'cengci/getCengci.php', '', 'edit')).forEach(item => {
					if (index != 0) body.find('.cengci').append(new Option(item.name, item.id))
				});
				body.find(".tname").append(getTeacherList({ tname: sessionStorage["userName"] }))
				if (edit) {
					if (scale == 1) {

					}
					else {
						if (edit.ispay > 0) {
							body.find(".money").attr("readonly", "readonly");
							body.find(".oweafee").attr("readonly", "readonly");
							body.find(".name").attr("readonly", "readonly");
						}
					}
					//设置编辑信息
					body.find(".addOrUpdate").val(1);//修改
					body.find(".studentId").val(edit.id);//设置需要修改的学员id
					body.find(".name").val(edit.name);
					body.find(".phone").val(edit.phone);
					body.find(".cardid").val(edit.cardid);
					body.find(".mail").val(edit.mail);
					body.find(".sosperson").val(edit.sosperson);
					body.find(".sosphone").val(edit.sosphone);
					body.find(".school").val(edit.school);
					body.find(".major").val(edit.major);
					body.find(".money").val(edit.money);
					body.find(".chengben").val(edit.chengben);
					body.find(".remarks").val(edit.remarks);
					body.find(".unifiedExam").attr('checked', edit.unifiedExam == '0' ? false : true)
					body.find(".paper").attr('checked', edit.paper == '0' ? false : true)
					body.find(".baccalaureate").attr('checked', edit.baccalaureate == '0' ? false : true)
					body.find(".tname").append(getTeacherList(edit))//加载报名老师列表
					body.find(".cengci").val(edit.cengci);
					body.find(".educationType").val(edit.educationType);
					body.find(".signUpTime").val(edit.signUpTime);
					body.find(".signUpYear").val(edit.signUpYear);
					body.find(".veteran").val(edit.veteran);
				} else {
					body.find(".addOrUpdate").val(0);//添加
				}
				setTimeout(function () {
					layui.layer.tips('点击此处返回学员列表', '.layui-layer-setwin .layui-layer-close', {
						tips: 3
					});
				}, 500)
			}
		})
		//layui.layer.full(index);
		sessionStorage.setItem("index", index);
		//改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
	}
	$(".addNews_btn").click(function () {
		editStudent();
	})

	$('.selfFilling').hover(function () {
		tips_info = layui.layer.tips('点击复制填报地址', this, { tips: [1, '#2F4056'], time: 3000 });
	}, function () {
		layer.close(tips_info);
	})

	$('.selfFilling').click(function () {
		navigator.clipboard.writeText(`https://boyeit.com/enroll/index.html?company_id=${company_id}`)
		layer.msg('可通过鼠标右键 粘贴 或 CTRL + V 分享给学员！');
	})

	//为批量修改按钮绑定事件
	function batchUpdateBinding(elem, value, handleNum, msg) {
		elem.click(function () {
			if (value.val() != "") {
				if (table.checkStatus(tableIns.config.id).data.length > 0) {
					isUpdata(value.val(), handleNum, batch(table.checkStatus(tableIns.config.id)));
				} else {
					layer.msg('请勾选要修改的学员！');
				}
			} else {
				layer.msg(msg);
			}
		})
	}
	batchUpdateBinding($("label[for='tName']"), $('#tName'), 6, '请选择报名老师！');
	batchUpdateBinding($("label[for='school']"), $('#school'), 7, '请输入报考院校！');
	batchUpdateBinding($("label[for='updateYears']"), $('#updateYear'), 8, '请选择报名年份！');
	batchUpdateBinding($("label[for='updateTime']"), $('#updateTime'), 9, '请选择报名季度！');
	batchUpdateBinding($("label[for='updateVeteran']"), $('#updateVeteran'), 0, '请选择是否是退伍军人！');

	//右侧工具栏操作
	table.on('tool(studentList)', function (obj) {
		var layEvent = obj.event,
			layData = obj.data;
		if (layEvent === 'edit') { //编辑
			editStudent(layData);
		} else if (layEvent === 'fapiao') {//发票
			openBillView(layData);
		} else if (layEvent.split('|')[0] === 'update') {
			switch (layEvent.split('|')[1]) {
				case 'remarks':
					clickUpdate(layData, 'remarks', '备注', obj);
					break;
				case 'money':
					clickUpdate(layData, 'money', '缴费金额', obj);
					break;
				case 'oweafee':
					clickUpdate(layData, 'oweafee', '欠费金额', obj);
					break;
				case 'chengben':
					clickUpdate(layData, 'chengben', '成本', obj);
					break;
			}
		}
		else if (layEvent === 'upload') {
			$('#upload_' + layData.id).on('change', function (e) {
				if (this.files[0]) {
					const fileLastName = this.files[0].name.split('.')[this.files[0].name.split('.').length - 1];
					if (fileLastName == "rar" || fileLastName == "zip") {
						const loading = layer.msg('资料上传中，请稍候...', { icon: 16, time: false, shade: 0.7 });
						let formData = new FormData();
						formData.append('id', layData.id);
						formData.append('studentData', this.files[0], layData.name.trim() + '_' + layData.cardid.trim() + '.' + fileLastName);
						$.ajax({
							type: "post",
							url: baseUrl + "student/upload.php",
							data: formData,
							processData: false,
							contentType: false,
							success: function (data) {
								if (data == '1') {
									layer.close(loading);
									layer.msg('上传成功！');
									tableIns.reload();
								} else {
									layer.close(loading);
									layer.msg('上传失败！');
								}
							}
						});
					} else {
						layer.msg('只支持压缩文件 ZIP 或 RAR 格式！');
					}
				}
			})
			$('#upload_' + layData.id).click();
		}
	});

	table.on('rowDouble(studentList)', function (obj) {
		editStudent(obj.data);
	});

	function clickUpdate(layData, attr, msg, obj) {
		if (layData.ispay == 1 && scale == 1) {

		} else if (layData.ispay == 1) {
			if (attr == "money" || attr == "oweafee" || attr == "chengben") {
				layer.msg('已缴费不能操作！');
				return;
			}
		}

		layer.prompt({
			formType: 2,
			title: '修改学员 [' + layData.name + '] 的' + msg + '信息',
			value: layData[attr]
		}, function (value, index) {
			layer.close(index);
			$.ajax({
				url: baseUrl + "student/update" + attr.toUpperCase() + ".php",
				data: {
					id: layData.id,
					[attr]: value
				},
				type: "POST",
				dataType: "text",
				success: function (data) {
					if (data == "1") {
						//同步更新表格和缓存对应的值
						obj.update({
							[attr]: value
						});
					}
				}
			})
		});
	}
	//获取报名老师列表
	function getTeacherList(edit) {
		var str = ``;
		$.ajax({
			url: baseUrl + "student/tName.php",
			data: { company_id },
			type: "GET",
			async: false,
			dataType: "text",
			success: function (data) {
				tnameList = JSON.parse(data);
				tnameList.forEach(function (item, index) {
					if (item.tname == edit.tname) {
						str += `<option value="${item.id}" selected>${item.tname}</option>`
					} else {
						str += `<option value="${item.id}">${item.tname}</option>`
					}
				})
			}
		})
		return str;
	}
	//批量操作
	function isUpdata(parameter, num, checkQuery) {
		$.ajax({
			url: baseUrl + "student/checkisPay.php",
			data: {
				parameter,
				num,
				checkQuery,
				user_id,
				recycle_bin: $('#recycle_bin').val()
			},
			type: "POST",
			dataType: "text",
			success: function (data) {
				if (data != "0") {
					layer.msg('操作成功！')
					tableIns.reload()
				} else {
					layer.msg('操作失败！')
				}
			}
		})
	}
	//打开发票视图
	function openBillView(data) {
		sessionStorage.removeItem("name");
		sessionStorage.removeItem("tname");
		sessionStorage.removeItem("educationType");
		sessionStorage.removeItem("money");
		sessionStorage.setItem('name', data.name); //学生姓名
		sessionStorage.setItem('tname', data.tname); //报名老师
		sessionStorage.setItem('educationType', mapWrite(data.educationType)); //学历类型
		sessionStorage.setItem('money', toChinesNum(data.money)); //缴费金额
		window.open("bill.html", '打印发票', 'width=' + 800 + ',height=' + 600 + ',left=' + (window.screen.width - 800) / 2 + ',top=' + (window.screen.height - 600) / 2 + ',resizable=no,status=yes,toolbar=no,location=no,menubar=no,menu=yes,scrollbars=yes');
	}
	//完成将 toChineseNum， 可以将数字转换成中文大写的表示，处理到万级别，例如 toChineseNum(12345)，返回 壹万贰仟叁佰肆拾五。
	function toChinesNum(num) {
		let changeNum = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']; //changeNum[0] = "零"
		let unit = ["", "拾", "佰", "仟", "万"];
		num = parseInt(num);
		let getWan = (temp) => {
			let strArr = temp.toString().split("").reverse();
			let newNum = "";
			for (var i = 0; i < strArr.length; i++) {
				newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum;
			}
			return newNum;
		}
		let overWan = Math.floor(num / 10000);
		let noWan = num % 10000;
		if (noWan.toString().length < 4) noWan = "0" + noWan;
		return overWan ? getWan(overWan) + "万" + getWan(noWan) + '元整' : getWan(num) + '元整';
	}
	//确认返费isRefund
	function isRefund(id, checkQuery) {
		if (scale != "1") return
		$.ajax({
			url: baseUrl + "student/updateIsFanMoney.php",
			data: {
				id: id,
				num: 1,
				checkQuery: checkQuery
			},
			type: "POST",
			dataType: "text",
			success: function (data) {
				if (data != "0") {
					layer.msg('操作成功！')
					tableIns.reload()
				} else {
					layer.msg('操作失败！')
				}
			}
		})
	}
})